package com.hl.controller;

import com.hl.domain.Teacher;
import com.hl.service.TeacherService;
import com.hl.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author Hr
 * @date 2024/9/6 9:01
 */
@RestController
@RequestMapping("/teacher")
public class TeacherController {

    @Autowired
    private TeacherService teacherService;

    //查询所有老师
    @GetMapping("/findAllTeacher")
    public R findAllTeacher() {
        List<Teacher> allTeacher = teacherService.findAllTeacher();
        return allTeacher != null ? R.success(allTeacher) : R.fail(allTeacher);
    }

    //根据老师id查等级,老师表与登等级表连接
    @GetMapping("/selectLevel")
    public R selectLevelByTeacherId(int id){
        return R.success(teacherService.selectLevelByTeacherId(id));
    }

    //小程序专用
    //查询所有老师，以及相关信息
    @GetMapping("/selectTeacherInfo")
    public R selectAllTeacherInfo(int page,int size){
        return R.success(teacherService.selectAllTeacherInfo(page,size));
    }

    //根据id查询老师信息
    @GetMapping("/selectAllById")
    public R selectAllById(int id){
        return R.success(teacherService.selectAllById(id));
    }


 	@GetMapping("/findAllAndChild")
    public R findAllAndChild(){
        return R.success(teacherService.findAllAndChild());
    }
    @GetMapping("/findAllAndChild2")
    public R findAllAndChild2(){
        return R.success(teacherService.findAllAndChild2());
    }

	//查询收费信息
    @GetMapping("/selectCharge")
    public R selectCharge(int id){
        return R.success(teacherService.selectCharge(id));
    }


    //回复留言展示
    @GetMapping("/selectProblemAndAnswer")
    public R selectProblemAndAnswer(){
        return R.success(teacherService.selectProblemAndAnswer());
    }

    //查询用户评价
    @GetMapping("/selectUserMarkById")
    public R selectUserMarkById(int id){
        return R.success(teacherService.selectUserMarkById(id));
    }


}
